/*
 * Created on 10/10/2011 - 4:00 AM
 */
package sembr.vtk.reader;

import sembr.vtk.persistence.ISavable;
import sembr.vtk.writer.VtkXmlDataSetWriter;
import vtk.vtkPolyData;

/**
 *
 * @author Adriano
 */
public abstract class ReaderBase implements ISavable
{
    private String filePath = null;
    
    public ReaderBase()
    {
        String javaLibPath = System.getProperty("java.library.path");
        LoadVTKLibraries();
    }
         
    @Override
    public void saveXmlFormat(String fileName)
    {
        VtkXmlDataSetWriter testWriter = new VtkXmlDataSetWriter(fileName, getPolyData());
        testWriter.writeFile();
    }
    
    protected void setFilePath(String filePath)
    {
        this.filePath = filePath;
    }
    
    protected String getFilePath()
    {
        if (filePath == null) 
            return "File not set!";
        
        return filePath;
    }
    
    private static void LoadVTKLibraries()
    {
        System.loadLibrary("vtkCommon");
        System.loadLibrary("vtkFiltering");
        System.loadLibrary("vtkGenericFiltering");
        System.loadLibrary("vtkGraphics");
        System.loadLibrary("vtkImaging");
        System.loadLibrary("vtksys");
        System.loadLibrary("vtkexpat");
        System.loadLibrary("vtkfreetype");
        System.loadLibrary("vtkftgl");
        System.loadLibrary("vtkjpeg");
        System.loadLibrary("vtkzlib");
        System.loadLibrary("vtktiff");
        System.loadLibrary("vtkpng");
        System.loadLibrary("vtkIO");
        System.loadLibrary("vtkRendering");
        System.loadLibrary("vtkVolumeRendering");
        System.loadLibrary("vtkCommonJava");
        System.loadLibrary("vtkFilteringJava");
        System.loadLibrary("vtkGenericFilteringJava");
        System.loadLibrary("vtkGraphicsJava");
        System.loadLibrary("vtkHybridJava");
        System.loadLibrary("vtkImagingJava");
        System.loadLibrary("vtkIOJava");
        System.loadLibrary("vtkGraphicsJava");
        System.loadLibrary("vtkRenderingJava");
        System.loadLibrary("vtkVolumeRenderingJava");
        System.loadLibrary("vtkWidgetsJava");
    }
       
    abstract public vtkPolyData getPolyData();  
}
